<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"  %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

    
<script>
	

	function goLogin() {
		
		if (!$('#user_id').val()) {
			bs_alert.msg('아이디를 입력해주세요.', 'danger');
			return;
		}
		
		if (!$('#password').val()) {
			bs_alert.msg('비밀번호를 입력해주세요.', 'danger');
			return;
		}
		
		var fdata = $("#form").serializeArray();
		
		$.ajax({
			url : "<c:url value="/login/loginMemberCheckStatus.json"/>",
			data : fdata,
			type : 'POST',
			cache : false,
			dataType : 'html',
			success : function(rtnData) {

				if (rtnData == '9') {
					bs_alert.warning('아이디가 없거나, 비밀번호 오류 입니다.', 'danger');
					return;
				} else if(rtnData == '4') {
					bs_alert.warning('해당 계정은 접근 하실 수 없습니다.', 'danger');
					return;
				} else if (rtnData == '0') {
					$('form').prop({action:'/login/submitLogin.ur', method:'post'}).submit();
				}
			}
			
		}).done(function() {
			
		});
		
	}
</script>

<div class="panel-heading">
	<h3 class="panel-title">urERP - Login</h3>
</div>
<div class="panel-body">
	<form role="form" id="form" name="form" method="post">
		<fieldset>
			<div class="form-group">
				<input class="form-control" id="user_id" name="user_id" placeholder="아이디" autofocus="autofocus" required="required">
			</div>
			<div class="form-group">
				<input class="form-control" id="password" name="password" type="password" placeholder="비밀번호" required="required" value="" onkeydown="javascript:if (event.keyCode == 13) { goLogin(); return false; } ">
			</div>
			<div class="checkbox">
				<label> <input name="remember" type="checkbox" value="Remember Me">자동 로그인
				</label>
			</div>
			
			<div id="alert_placeholder" style="display:none;"></div>
			
			<!-- Change this to a button or input when using this as a form -->
			<a href="javascript:goLogin();" id="login_btn" class="btn btn-lg btn-success btn-block">Login</a>

		</fieldset>
		
		
	</form>
</div>